#include "log.h"
#include "NTPClient.h"
#include "WiFiUdp.h"

WiFiUDP g_ntp_udp;
NTPClient g_time_client(g_ntp_udp, "pool.ntp.org", 8 * 60 * 60);

void LOG(int log_type, char *log)
{
    g_time_client.update();

    unsigned long epco_time = g_time_client.getEpochTime();
    Serial.printf("...epco:%lu\n", epco_time);
    tm *date_time = gmtime((time_t *)&epco_time);
    Serial.printf("%04d-%02d-%02d ", date_time->tm_year + 1900, date_time->tm_mon + 1, date_time->tm_mday);

    Serial.print(g_time_client.getFormattedTime());
    Serial.print(" ");
    Serial.println(log);
}